package com.vcredit.creditcat.manager.product.h5;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.vcredit.creditcat.api.product.h5.IAfterCreditManager;
import com.vcredit.creditcat.dto.product.h5.BindBankCardParamDto;
import com.vcredit.creditcat.dto.product.h5.CheckOrderResultDto;
import com.vcredit.creditcat.dto.product.h5.CreateOrderParamDto;
import com.vcredit.creditcat.dto.product.h5.LoanBindCardListDto;
import com.vcredit.creditcat.dto.product.h5.LoanOrderIndexDto;
import com.vcredit.creditcat.dto.product.h5.QueryBankByCardResultDto;
import com.vcredit.creditcat.dto.product.h5.QueryContractResultDto;
import com.vcredit.creditcat.dto.product.h5.QueryOrderStatusResultDto;
import com.vcredit.creditcat.dto.product.h5.SdOrderReviewInfoDto;
import com.vcredit.creditcat.dto.product.h5.SdTryCalculateParamDto;
import com.vcredit.creditcat.dto.product.h5.SdTryCalculateResultDto;
import com.vcredit.creditcat.dto.product.h5.SubmitBindCardParamDto;
import com.vcredit.creditcat.dto.product.h5.TryCalculateParamDto;
import com.vcredit.creditcat.dto.product.h5.TryCalculateResultDto;
import com.vcredit.creditcat.model.Cust;
import com.vcredit.creditcat.service.product.h5.AfterCreditService;
import com.vcredit.creditcat.service.product.h5.SdAfterCreditService;
import com.vcredit.framework.exception.BaseException;

@Service(protocol = { "protocol1" }, version = "1.0")
public class AfterCreditManager implements IAfterCreditManager {
	
	@Autowired
	private AfterCreditService commonAfterCreditService;
	@Autowired
	private SdAfterCreditService sdAfterCreditService;
	@Autowired
	private AfterCreditService afterCreditService;
	
	@Override
	public CheckOrderResultDto checkUser(Long productId, Cust cust) throws Exception {
		if(productId == 3) {
			return sdAfterCreditService.checkUser(productId, cust);
		}
		return commonAfterCreditService.checkUser(productId,cust);
	}

	@Override
	public TryCalculateResultDto tryCalculate(Long productId, TryCalculateParamDto param, Cust cust)
			throws Exception {
		return commonAfterCreditService.tryCalculate(productId, param, cust);
	}
	
	@Override
	public SdTryCalculateResultDto sdTryCalculate(SdTryCalculateParamDto param,
			Cust cust) throws Exception {
		return sdAfterCreditService.sdTryCalculate(param, cust);
	}

	@Override
	public String submitLoan(Long productId, CreateOrderParamDto param, Cust cust)
			throws Exception {
		if(productId == 3) {
			return sdAfterCreditService.submitLoan(productId, param, cust);
		}
		return commonAfterCreditService.submitLoan(productId, param, cust);
	}

	@Override
	public SdOrderReviewInfoDto queryReviewInfo(Cust cust) throws Exception {
		return sdAfterCreditService.queryReviewInfo(cust);
	}

	@Override
	public void bindCard(Long productId, BindBankCardParamDto param, Cust cust) throws Exception{
		if(productId == 3) {
			sdAfterCreditService.bindCard(productId, param, cust);
		}
		commonAfterCreditService.bindCard(productId, param, cust);
	}

	@Override
	public QueryContractResultDto queryContract(Long productId, Cust cust)
			throws Exception {
		return commonAfterCreditService.queryContract(productId, cust);
	}

	@Override
	public QueryOrderStatusResultDto queryOrderStatus(Long productId, Cust cust) throws Exception {
		return commonAfterCreditService.queryOrderStatus(productId, cust);
	}

	@Override
	public LoanBindCardListDto loanbindCardList(Long productId, Cust cust) {
		if(productId == 3) {
			return sdAfterCreditService.loanbindCardList(cust);
		}
		return commonAfterCreditService.loanbindCardList(productId, cust);
	}

	@Override
	public Boolean submitBindCard(Long productId, SubmitBindCardParamDto param,
			Cust cust) throws Exception {
		return commonAfterCreditService.submitBindCard(productId, param, cust);
	}

	@Override
	public LoanOrderIndexDto loanOrderIndex(Long productId,Cust cust)
			throws Exception {
		return commonAfterCreditService.loanOrderIndex(productId,cust);
	}

	@Override
	public LoanBindCardListDto bankInfoList() {
		return commonAfterCreditService.bankInfoList();
	}

	@Override
	public QueryBankByCardResultDto queryBankByCard(String bankCard) throws Exception {
		return commonAfterCreditService.queryBankByCard(bankCard);
	}

	@Override
	public Cust queryCustInfo(Cust cust) throws BaseException {
		return commonAfterCreditService.queryCustInfo(cust);
	}

	@Override
	public String queryJump(Cust cust, Long productId) throws Exception {
		return commonAfterCreditService.queryJump(cust,productId);
	}

	@Override
	public void updateLoanOrderStatus(Long productId, String order_id, Integer order_status) throws BaseException {
		afterCreditService.updateLoanOrderStatus(productId,order_id,order_status);
	}

	@Override
	public void uploadSignature(Cust cust, Long productId, String signatureImg) throws BaseException {
		afterCreditService.uploadSignature(cust,productId,signatureImg);
	}
	
	
	@Override
	public String sdGetDeviceId(Cust cust) throws BaseException {
		return afterCreditService.sdGetDeviceId(cust);
	}
	
	@Override
	public String sdGetCreditAmt(Cust cust, Long productId) throws BaseException {
		return afterCreditService.sdGetCreditAmt(cust,productId);
	}

}
